package com.tarena.lbs.user.dao.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tarena.lbs.user.dao.mapper.UserMapper;
import com.tarena.lbs.user.dao.repository.UserRepository;
import com.tarena.lbs.user.pojo.po.UserPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class  UserRepositoryImpl implements UserRepository {

    @Autowired
    private UserMapper userMapper;

    @Override
    public UserPO save(UserPO user) {
        userMapper.insert(user);
        return user;
    }

    @Override
    public UserPO findByPhone(String phone) {
        LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserPO::getPhone, phone);
        return userMapper.selectOne(wrapper);
    }

    @Override
    public UserPO findById(Integer id) {
        return userMapper.selectById(id);
    }

    @Override
    public UserPO getUserByPhone(String phone) {
        return null;
    }
} 